<?php

$redis = new Redis();  
$redis->connect('127.0.0.1',6379); 

$redis->set('test','123456'); 
$redis->set('test1','afad'); 
echo $redis->get('test');  
echo "</br>";  
//生存时间，默认返回-1  
echo $redis->ttl('test');  
echo "</br>";  
//设置生存时间  
$redis->setex('key', 7, 'val');  
echo $redis->ttl('key');  
echo "</br>";  
////查找有返回1  
//echo $redis->exists('test');  
//echo "</br>///";  

echo "Server is running: " . $redis->ping();